﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace TFSTools.TFSLibrary
{
    /// <summary>
    /// TFSNotConnectedException Exception
    /// </summary>
    public class TFSNotConnectedException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSNotConnectedException"/> class.
        /// </summary>
        public TFSNotConnectedException() : base("Team Foundation Server is not connected.") { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSNotConnectedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public TFSNotConnectedException(string message) : base(message) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSNotConnectedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public TFSNotConnectedException(string message, Exception innerException) : base(message, innerException) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSNotConnectedException"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
        ///   
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
        protected TFSNotConnectedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }

    /// <summary>
    /// TFSFieldNotExistException Exception
    /// </summary>
    public class TFSFieldNotExistException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSFieldNotExistException"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        public TFSFieldNotExistException(string fieldName) : base(string.Format("A field definition {0} in the work item type definition file does not exist. Add a definition for this field or remove the reference to the field and try again.", fieldName)) { }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSFieldNotExistException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public TFSFieldNotExistException(string fieldName, Exception innerException) : base(string.Format("A field definition {0} in the work item type definition file does not exist. Add a definition for this field or remove the reference to the field and try again.", fieldName), innerException) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSFieldNotExistException"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
        ///   
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
        protected TFSFieldNotExistException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }

    public class TFSUnauthorizedException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUnauthorizedException"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        public TFSUnauthorizedException(string serverName) : base(string.Format("You are not authorized to access {0}.", serverName)) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUnauthorizedException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public TFSUnauthorizedException(string serverName, Exception innerException) : base(string.Format("You are not authorized to access {0}.", serverName), innerException) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUnauthorizedException"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
        ///   
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
        protected TFSUnauthorizedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }

    public class TFSLogOnException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSLogOnException"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        public TFSLogOnException(string message) : base("TFS Login Failed - " + message) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSLogOnException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public TFSLogOnException(string message, Exception innerException) : base("TFS Login Failed - " + message, innerException) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSLogOnException"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
        ///   
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
        protected TFSLogOnException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }

    public class TFSUserNotFoundException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUserNotFoundException"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        public TFSUserNotFoundException(string message) : base("TFS User Not Found - " + message) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUserNotFoundException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public TFSUserNotFoundException(string message, Exception innerException) : base("TFS User Not Found - " + message, innerException) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TFSUserNotFoundException"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
        ///   
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
        protected TFSUserNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }
}
